home *** CD-ROM | disk | FTP | other *** search
/ MACD 5 / MACD 5.bin / workbench / blankery / blanker / source / blankers / clock / prefs.c < prev    next >
C/C++ Source or Header  |  1993-07-25  |  4KB  |  157 lines

  1. #include <exec/types.h>
  2. #include <exec/memory.h>
  3.  
  4. #include <dos/dos.h>
  5.  
  6. #include <intuition/intuition.h>
  7. #include <intuition/screens.h>
  8. #include <intuition/gadgetclass.h>
  9. #include <libraries/gadtools.h>
  10. #include <libraries/asl.h>
  11. #include <graphics/text.h>
  12.  
  13. #include <clib/exec_protos.h>
  14. #include <clib/intuition_protos.h>
  15. #include <clib/dos_protos.h>
  16. #include <clib/gadtools_protos.h>
  17. #include <clib/asl_protos.h>
  18.  
  19. #include "Clock.h"
  20. #include "Clock_rev.h"
  21. #include "/defs.h"
  22.  
  23. struct cPrefObject {
  24.     UBYTE fName[64], Speed, Cycle, Secs, Military;
  25.     struct TextAttr Font;
  26. };
  27.  
  28. VOID blank( VOID );
  29.  
  30.     struct    cPrefObject    nP;
  31. STATIC    const    UBYTE    VersTag[] = VERSTAG;
  32. extern    struct    Task    **Task;
  33. extern          ULONG   Depth, Mode;
  34. extern          UBYTE   *prefData;
  35.     
  36. VOID setClockPrefs( VOID )
  37. {
  38.         GT_SetGadgetAttrs( ClockGadgets[GD_SPEED], ClockWnd, 0L, GTSL_Level, nP.Speed, 0L );
  39.     GT_SetGadgetAttrs( ClockGadgets[GD_FTXT], ClockWnd, 0L, GTTX_Text, nP.fName, 0L );
  40.     GT_SetGadgetAttrs( ClockGadgets[GD_FSIZE], ClockWnd, 0L, GTNM_Number, nP.Font.ta_YSize, 0L );
  41.     GT_SetGadgetAttrs( ClockGadgets[GD_MIL], ClockWnd, 0L, GTCY_Active, nP.Military, 0L );
  42.     GT_SetGadgetAttrs( ClockGadgets[GD_CYCLE], ClockWnd, 0L, GTCY_Active, nP.Cycle, 0L );
  43.     GT_SetGadgetAttrs( ClockGadgets[GD_SECS], ClockWnd, 0L, GTCY_Active, nP.Secs, 0L );
  44. }
  45.  
  46. int OKClicked( VOID )
  47. {
  48.     CopyMem( &nP, prefData, sizeof( struct cPrefObject ));
  49.     return( QUIT );
  50. }
  51.  
  52. int TESTClicked( VOID )
  53. {
  54.     *Task = FindTask( 0L );
  55.     blank();
  56.     return( CONTINUE );
  57. }
  58.  
  59. int CANCELClicked( VOID )
  60. {
  61.     return( QUIT );
  62. }
  63.  
  64. int SPEEDClicked( VOID )
  65. {
  66.     nP.Speed = ClockMsg.Code;
  67.     return( CONTINUE );
  68. }
  69.  
  70. int MILClicked( VOID )
  71. {
  72.     nP.Military = ClockMsg.Code;
  73.     return( CONTINUE );
  74. }
  75.  
  76. int CYCLEClicked( VOID )
  77. {
  78.     nP.Cycle = ClockMsg.Code;
  79.     return( CONTINUE );
  80. }
  81.  
  82. int SECSClicked( VOID )
  83. {
  84.     nP.Secs = ClockMsg.Code;
  85.     return( CONTINUE );
  86. }
  87.  
  88. int FONTClicked( VOID )
  89. {
  90.     struct FontRequester *fReq;
  91.  
  92.     if( fReq = ( struct FontRequester * )AllocAslRequestTags( ASL_FontRequest, ASL_FontName, (ULONG)nP.fName,
  93.         ASL_FontHeight, nP.Font.ta_YSize, ASL_MaxHeight, 100, TAG_DONE )) {
  94.         if( AslRequestTags( fReq, ASLFO_Window, ClockWnd, ASLFO_SleepWindow, TRUE, ASLFO_TitleText,
  95.             (ULONG)"Please choose a font...", 0L )) {
  96.             CopyMem( fReq->fo_Attr.ta_Name, nP.fName, 31 );
  97.             nP.Font.ta_YSize = fReq->fo_Attr.ta_YSize;
  98.         }
  99.         FreeAslRequest( fReq );
  100.     }
  101.     setClockPrefs();
  102.     return( CONTINUE );
  103. }
  104.  
  105. int ClockVanillaKey( VOID )
  106. {
  107.     switch( ClockMsg.Code ) {
  108.     case 'o':
  109.         return( OKClicked() );
  110.     case 't':
  111.         return( TESTClicked() );
  112.     case 'c':
  113.         return( CANCELClicked() );
  114.     case 'f':
  115.         return( FONTClicked());
  116.     case 's':
  117.         GT_SetGadgetAttrs( ClockGadgets[GD_SPEED], ClockWnd, 0L, GTSL_Level, ++(nP.Speed) > 50 ?
  118.             nP.Speed = 50 : nP.Speed, 0L );
  119.         return( CONTINUE );
  120.     case 'S':
  121.         GT_SetGadgetAttrs( ClockGadgets[GD_SPEED], ClockWnd, 0L, GTSL_Level, --(nP.Speed) < 1 ?
  122.             nP.Speed = 1 : nP.Speed, 0L );
  123.         return( CONTINUE );
  124.     default:
  125.         return( CONTINUE );
  126.     }
  127. }
  128.  
  129. VOID prefs( LONG command )
  130. {
  131.     switch( command ) {
  132.     case STARTUP:
  133.         if( !ClockWnd ) {
  134.             CopyMem( prefData, &nP, sizeof( struct cPrefObject ));
  135.             nP.Font.ta_Name = nP.fName;
  136.             if( !SetupScreen() ) {
  137.                 if( !OpenClockWindow()) setClockPrefs();
  138.                 CloseDownScreen();
  139.             }
  140.         } else {
  141.             ActivateWindow( ClockWnd );
  142.             WindowToFront( ClockWnd );
  143.         }
  144.         break;
  145.     case IDCMP:
  146.         if( HandleClockIDCMP() != QUIT ) break;
  147.     case KILL:
  148.         CloseClockWindow();
  149.         break;
  150.     }
  151. }
  152.  
  153. LONG winSig( VOID )
  154. {
  155.     return( ClockWnd ? ( 1L << ClockWnd->UserPort->mp_SigBit ) : 0L );
  156. }
  157.